//
//  OPEveryDayQustionView.m
//  OpenPractice
//
//  Created by red on 2021/10/25.
//  Copyright © 2021 tanyuehong. All rights reserved.
//

#import <SDWebImage/SDWebImage.h>
#import "OPEveryDayQustionView.h"

@interface  OPEveryDayQustionView ()

@property (nonatomic,strong) UILabel *qustionLable;
@property (nonatomic,strong) UIImageView *imageView;
@property (nonatomic,strong) UIImageView *imageArrorView;

@end

@implementation OPEveryDayQustionView

- (instancetype)init {
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setImageUrl:(NSString *)imageUrl {
    if ([imageUrl hasPrefix:@"http"]) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:nil];
    } else {
        self.imageView.image = [UIImage imageNamed:imageUrl];
    }
}

- (void)setImageArrowUrl:(NSString *)imageArrowUrl {
    if ([imageArrowUrl hasPrefix:@"http"]) {
        [self.imageArrorView sd_setImageWithURL:[NSURL URLWithString:imageArrowUrl] placeholderImage:nil];
    } else {
        self.imageArrorView.image = [UIImage imageNamed:imageArrowUrl];
    }
}

- (void)setQustionName:(NSString *)qustionName {
    self.qustionLable.text = qustionName;
}

- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        [self addSubview:_imageView];
        [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(90));
            make.height.equalTo(@(30));
            make.centerY.equalTo(self);
            make.left.equalTo(@(kAdaptedIpadWidth4(10)));
        }];
    }
    return _imageView;
}

- (UIImageView *)imageArrorView {
    if (!_imageArrorView) {
        _imageArrorView = [[UIImageView alloc] init];
        [self addSubview:_imageArrorView];
        [_imageArrorView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(28));
            make.height.equalTo(@(28));
            make.centerY.equalTo(self);
            make.left.mas_equalTo(self.imageView.mas_right).offset(5);
        }];
    }
    return _imageArrorView;
}

- (UILabel *)qustionLable {
    if (!_qustionLable) {
        _qustionLable = [[UILabel alloc] init];
        _qustionLable.numberOfLines = 0;
        _qustionLable.font = [UIFont systemFontOfSize:12];
        [self addSubview:_qustionLable];
        
        [_qustionLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.imageArrorView.mas_right).offset(3);
            make.height.equalTo(self);
            make.right.equalTo(self).offset(-10);
        }];
    }
    return _qustionLable;
}

@end
